<?php
/**
 * 活动管理
 * 
 * @author  Lee<a605333742@gmail.com>
 * @time    2016-08-09
 */
namespace Admin\Controller; 

class ClubController extends CommonController{
    /*
     * 构造函数
     * 
     * @return #
     */
    public function _initialize() {
        parent::_initialize();
        $this->db_club  =D("Club");
        $this->db_reply =D("Reply");
        $this->db_gClub =D("ClubGroup");
        $this->db_sec   =D("Section");
    }
    
    /*
     * index前置操作
     * 
     * @return #
     */
    public function _before_index(){
        if(I("request.groupName")){
            $map['club']    =$this->getIds(I("request.groupName"),"name","ClubGroup");
            $map['sec']     =$this->getIds(I("request.groupName"),"name","Section");
            $_REQUEST['group_id']=array_merge($map['club'],$map['sec']);
        }
        if(I("request.userName")){
            $_REQUEST['assign_user_id'] =A("Common")->getIds(I("request.userName"),"name","User");
        }
        if(I("request.validity")){
            $_REQUEST['validity']       =array("egt",I("request.validity"));
        }
    }
    
    /*
     * show前置操作
     * 
     * @return #
     */
    public function _before_show(){
        //查询俱乐部
        $clubGroupList  =$this->db_gClub->where(array("status"=>1))->select();
        $this->assign("clubGList",$clubGroupList);
        //查询部门
        $sectionList    =$this->db_sec->where(array("status"=>1))->select();
        $this->assign("secList",$sectionList);
        //查询活动列表
        if(I("request.sign")){
            $clubList   =$this->db_club->where(array('status'=>1))->select();
            $this->assign("clubList",$clubList);  
        }
    }
    
    /*
     * 活动回复
     * 
     * @return #
     */
    public function replyList(){
        A("Common")->index("Reply");
    }
    
    /*
     * edit前置操作
     * 
     * @return #
     */
    public function _before_edit(){
        if(I("request._sign")==1){
            $_POST['sign']      =time();
            $_POST['path_id']   =session("authId").'-';
        }else if(I("request._sign")==2){
            $path_id            =$this->db_reply->field('path_id,sign')->find(I("request.pre_id"));
            $_POST['path_id']   =$path_id['path_id'].session("authId").'-';
            $_POST['sign']      =$path_id['sign']."a";
        }
    }
    
    /*
     * 俱乐部列表
     * 
     * @return #
     */
    public function clubGlist(){
        A("Common")->index("ClubGroup");
    }
    
   /*
    * 上传活动图片 
    * 
    * @return #
    */
    public function upload_(){
        $club_id=I("request.id",'','code');
        $this->assign("club_id",$club_id);
        $this->display();
    }
    
    /*
     * 图片上传处理
     * 
     * @return #
     */
    public function edit_(){
        $this->success("上传成功");
    }
    
    /*
     * 活动照片
     * 
     * @return #
     */
    public function imgList(){
        A("Common")->index("ClubImg");
    }
}